import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'
import { resolve } from 'path';
import config from "./config";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), styleImport({
    libs: [{
      libraryName: 'element-plus',
      esModule: true,
      ensureStyleFile: true,
      resolveStyle: (name) => {
        // name = name.slice(3)
        return `element-plus/lib/theme-chalk/${name}.css`;
      },
      resolveComponent: (name) => {
        return `element-plus/lib/${name}`;
      },
    }]
  })],
  optimizeDeps: {
    exclude: ["vuex"]
  },
  server: {
    host: '0.0.0.0',
    port: 8889,
    proxy: {
      '/api': {
        target: config.baseUrl.dev,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    },
    // cors: true
    // open: true
  },
  resolve: {
    alias: {
      "@": resolve("src")
    }
  }
})
